package listenner;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class MySessionListenner implements HttpSessionListener {
	public static int onlineCount = 0;

	@Override
	public void sessionCreated(HttpSessionEvent evt) {
		onlineCount ++;
		System.out.println("++++++++++++++++++++++++++++++++++++++");
		System.out.println("New session: id=" + evt.getSession().getId());
		System.out.println("online count = " + onlineCount);
	}

	@Override
	public void sessionDestroyed(HttpSessionEvent evt) {
		onlineCount --;
		System.out.println("---------------------------");
		System.out.println("online Count = " + onlineCount);
	}

	public int getOnlineCount() {
		return onlineCount;
	}


}
